<xsl:stylesheet version = '1.1' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="text" />

<xsl:template match="table">
<xsl:variable name="table_name" select="@name" />
CREATE OR REPLACE PACKAGE <xsl:value-of select="$table_name"/>_API
IS
/*******************************
* API Package for "<xsl:value-of select="@name"/>" table
*******************************/

PROCEDURE ins(
<xsl:for-each select="columns">
   <xsl:for-each select="column">
      <xsl:text>&#x9;</xsl:text>
      <xsl:variable name="name_var" select="@name"/>
      <xsl:value-of select="$name_var"/>_i <xsl:value-of select="$table_name"/>.<xsl:value-of select="$name_var"/>%TYPE<xsl:choose><xsl:when test="position() != last()">,<xsl:text>&#xa;</xsl:text></xsl:when></xsl:choose>
      </xsl:for-each>
   </xsl:for-each>
);

END <xsl:value-of select="@name"/>_API;
/
</xsl:template>

</xsl:stylesheet>
